package featuremodel.constraint;

import java.util.Vector;

import featuremodel.FeatureGroup;
import featuremodel.FeatureModelDef;
import featuremodel.method.RequireCompositeMethodSetBind;
import featuremodel.method.RequireCompositeMethodSetUnbind;

import skyblue.Method;
import skyblue.Strength;

public class RequireCompositeConstraint extends CompositeConstraint {
	private Vector<Method> methods1;

	public RequireCompositeConstraint(FeatureGroup featureGroup1,
			String g1Type, FeatureGroup featureGroup2, String g2Type,
			Strength strength) {

		super(strength);

		this.constraintType = FeatureModelDef.REQUIRE_COMPLEX_CONSTRAINT;

		getVariables().addAll(featureGroup1.getVariables());
		getVariables().addAll(featureGroup2.getVariables());

		// Method1
		setGroupPredicTrue(featureGroup2, g2Type);
		methods1 = getTempMethods();
		for (int i = 0; i < methods1.size(); i++) {
			getMethods()
					.add(new RequireCompositeMethodSetBind(methods1.get(i)));
		}

		if (methods1 != null) {
			methods1.clear();
		}

		// Method2
		setGroupPredicFalse(featureGroup1, g1Type);
		methods1 = getTempMethods();
		for (int i = 0; i < methods1.size(); i++) {
			getMethods().add(
					new RequireCompositeMethodSetUnbind(methods1.get(i)));
		}

	}

}
